import { createApp } from 'vue';
import App from './App.vue';

//ElementUI
import ElementPlus from 'element-plus'
import zhCn from 'element-plus/es/locale/lang/zh-cn'

// ElementUI图标
import * as ElementPlusIconsVue from '@element-plus/icons-vue'

//路由
import router from './router';
//状态管理
import store from './store';

//引入API
import mainApi from '@/api';

//引入全局方法
import common from '@/utils/common';

// 路由守卫
import '@/permission';

// 权限判断指令
import permission from '@/directive/permission/index.js';

// 全局样式
import '@/styles/index.scss';

// svg图标：引入注册脚本
import 'virtual:svg-icons-register';

// 引入组件
import SvgIcon from '@/components/SvgIcon/index.vue';

//引入iconfont图标
import '@/assets/iconfont/iconfont.js';
import '@/assets/iconfont/iconfont.css';

//表单组件
import LayJsonSchemaForm from '@layui/json-schema-form';
import '@layui/json-schema-form/lib/index.css';

// 引入 echarts
import echarts from "@/utils/ECharts";

const app = createApp(App);

app.config.globalProperties.$http = mainApi; //设置全局api
app.config.globalProperties.$common = common; //设置全局方法
app.config.globalProperties.$echarts = echarts; //echarts

// 路由跳转
app.config.globalProperties.$routerGo = function(url) {
	router.push({
		path: url
	});
};

for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
	app.component(key, component)
}

app.use(store).use(router).use(ElementPlus, { locale: zhCn, }).use(LayJsonSchemaForm).use(permission);

app.component('SvgIcon', SvgIcon); // 全局组件挂载

app.mount('#app');